home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / syntax / python.vim < prev    next >
Encoding:
Text File  |  2001-05-14  |  5.4 KB  |  152 lines

  1. " Vim syntax file
  2. " Language:    Python
  3. " Maintainer:    Neil Schemenauer <nas@python.ca>
  4. " Updated:    2001-05-13
  5. "
  6. " There are four options to control Python syntax highlighting.
  7. "
  8. " For highlighted numbers:
  9. "
  10. "    let python_highlight_numbers = 1
  11. "
  12. " For highlighted builtin functions:
  13. "
  14. "    let python_highlight_builtins = 1
  15. "
  16. " For highlighted standard exceptions:
  17. "
  18. "    let python_highlight_exceptions = 1
  19. "
  20. " If you want all possible Python highlighting (the same as setting the
  21. " preceding three options):
  22. "
  23. "    let python_highlight_all = 1
  24. "
  25.  
  26. " For version 5.x: Clear all syntax items
  27. " For version 6.x: Quit when a syntax file was already loaded
  28. if version < 600
  29.   syntax clear
  30. elseif exists("b:current_syntax")
  31.   finish
  32. endif
  33.  
  34.  
  35. syn keyword pythonStatement    break continue del
  36. syn keyword pythonStatement    except exec finally
  37. syn keyword pythonStatement    pass print raise
  38. syn keyword pythonStatement    return try
  39. syn keyword pythonStatement    global assert
  40. syn keyword pythonStatement    lambda
  41. syn keyword pythonStatement    def class nextgroup=pythonFunction skipwhite
  42. syn match   pythonFunction    "[a-zA-Z_][a-zA-Z0-9_]*" contained
  43. syn keyword pythonRepeat    for while
  44. syn keyword pythonConditional    if elif else
  45. syn keyword pythonOperator    and in is not or
  46. syn keyword pythonPreCondit    import from
  47. syn match   pythonComment    "#.*$" contains=pythonTodo
  48. syn keyword pythonTodo        contained TODO FIXME XXX
  49.  
  50. " strings
  51. syn region pythonString        matchgroup=Normal start=+'+  end=+'+ skip=+\\\\\|\\'+ contains=pythonEscape
  52. syn region pythonString        matchgroup=Normal start=+"+  end=+"+ skip=+\\\\\|\\"+ contains=pythonEscape
  53. syn region pythonString        matchgroup=Normal start=+"""+  end=+"""+ contains=pythonEscape
  54. syn region pythonString        matchgroup=Normal start=+'''+  end=+'''+ contains=pythonEscape
  55. syn region pythonRawString    matchgroup=Normal start=+[rR]'+ end=+'+ skip=+\\\\\|\\'+
  56. syn region pythonRawString    matchgroup=Normal start=+[rR]"+    end=+"+ skip=+\\\\\|\\"+
  57. syn region pythonRawString    matchgroup=Normal start=+[rR]"""+ end=+"""+
  58. syn region pythonRawString    matchgroup=Normal start=+[rR]'''+ end=+'''+
  59. syn match  pythonEscape        +\\[abfnrtv'"\\]+ contained
  60. syn match  pythonEscape        "\\\o\o\=\o\=" contained
  61. syn match  pythonEscape        "\\x\x\+" contained
  62. syn match  pythonEscape        "\\$"
  63.  
  64. if exists("python_highlight_all")
  65.   let python_highlight_numbers = 1
  66.   let python_highlight_builtins = 1
  67.   let python_highlight_exceptions = 1
  68. endif
  69.  
  70. if exists("python_highlight_numbers")
  71.   " numbers (including longs and complex)
  72.   syn match   pythonNumber    "\<0x\x\+[Ll]\=\>"
  73.   syn match   pythonNumber    "\<\d\+[LljJ]\=\>"
  74.   syn match   pythonNumber    "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
  75.   syn match   pythonNumber    "\<\d\+\.\([eE][+-]\=\d\+\)\=[jJ]\=\>"
  76.   syn match   pythonNumber    "\<\d\+\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
  77. endif
  78.  
  79. if exists("python_highlight_builtins")
  80.   " builtin functions, not really part of the syntax
  81.   syn keyword pythonBuiltin    abs apply callable chr cmp coerce
  82.   syn keyword pythonBuiltin    compile complex delattr dir divmod
  83.   syn keyword pythonBuiltin    eval execfile filter float getattr
  84.   syn keyword pythonBuiltin    globals hasattr hash hex id input
  85.   syn keyword pythonBuiltin    int intern isinstance issubclass
  86.   syn keyword pythonBuiltin    len list locals long map max min
  87.   syn keyword pythonBuiltin    oct open ord pow range raw_input
  88.   syn keyword pythonBuiltin    reduce reload repr round setattr
  89.   syn keyword pythonBuiltin    slice str tuple type vars xrange
  90. endif
  91.  
  92. if exists("python_highlight_exceptions")
  93.   " builtin exceptions
  94.   syn keyword pythonException    ArithmeticError AssertionError
  95.   syn keyword pythonException    AttributeError EOFError EnvironmentError
  96.   syn keyword pythonException    Exception FloatingPointError IOError
  97.   syn keyword pythonException    ImportError IndexError KeyError
  98.   syn keyword pythonException    KeyboardInterrupt LookupError
  99.   syn keyword pythonException    MemoryError NameError NotImplementedError
  100.   syn keyword pythonException    OSError OverflowError RuntimeError
  101.   syn keyword pythonException    StandardError SyntaxError SystemError
  102.   syn keyword pythonException    SystemExit TypeError ValueError
  103.   syn keyword pythonException    ZeroDivisionError
  104. endif
  105.  
  106.  
  107. " This is fast but code inside triple quoted strings screws it up. It
  108. " is impossible to fix because the only way to know if you are inside a
  109. " triple quoted string is to start from the beginning of the file. If
  110. " you have a fast machine you can try uncommenting the "sync minlines"
  111. " and commenting out the rest.
  112. syn sync match pythonSync grouphere NONE "):$"
  113. syn sync maxlines=200
  114. "syn sync minlines=2000
  115.  
  116. if version >= 508 || !exists("did_python_syn_inits")
  117.   if version <= 508
  118.     let did_python_syn_inits = 1
  119.     command -nargs=+ HiLink hi link <args>
  120.   else
  121.     command -nargs=+ HiLink hi def link <args>
  122.   endif
  123.  
  124.   " The default methods for highlighting.  Can be overridden later
  125.   HiLink pythonStatement    Statement
  126.   HiLink pythonFunction        Function
  127.   HiLink pythonConditional    Conditional
  128.   HiLink pythonRepeat        Repeat
  129.   HiLink pythonString        String
  130.   HiLink pythonRawString    String
  131.   HiLink pythonEscape        Special
  132.   HiLink pythonOperator        Operator
  133.   HiLink pythonPreCondit    PreCondit
  134.   HiLink pythonComment        Comment
  135.   HiLink pythonTodo        Todo
  136.   if exists("python_highlight_numbers")
  137.     HiLink pythonNumber    Number
  138.   endif
  139.   if exists("python_highlight_builtins")
  140.     HiLink pythonBuiltin    Function
  141.   endif
  142.   if exists("python_highlight_exceptions")
  143.     HiLink pythonException    Exception
  144.   endif
  145.  
  146.   delcommand HiLink
  147. endif
  148.  
  149. let b:current_syntax = "python"
  150.  
  151. " vim: ts=8
  152.